const BASE_URL = 'https://tea.qingnian8.com/api/bizhi'
// const header = {
// 	"access-key": "guest007"
// }
export function request(config={}) {
	const url = BASE_URL + config.url
	const {
		data = {},
		method = 'GET',
		// header = {},
	} = config
	// header['access-key'] = 'guest007'
	return new Promise((resolve, reject) => {
		uni.request({
			url,
			data,
			method,
			// header,
			success: res => {
				if (res.data.errCode === 0) {
					resolve(res.data)
				} else if(res.data.errCode === 400) {
					uni.showModal({
						title: '请求错误',
						content: res.data.errMsg,
						showCancel: false
					})
					reject(res.data)
				} else {
					uni.showToast({
						title: res.data.errMsg,
						icon: 'none'
					})
					reject(res.data)
				}
			},
			fail: err => {
				reject(err)
			}
		})
	})
}